//验证用户注册输入
function checkemail() {

    var email = $("#ctl00_ContentPlaceHolder1_email").val();
           var isemail=(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/);
           if (email==""){
                 htmlerror("请输入邮件地址","tdmail");
                 return false;
           }
           if (email.length>25){
                 htmlerror("邮件地址过长","tdmail");
                 return false
           }
           if (!isemail.test(email)){ 
                 htmlerror("邮件地址不正确","tdmail");
                 return false;
           }

           ajaxcheckemail(email);
           
           var ehave = $("#ehave").val();
           if(ehave=="yes"){
//                 htmlerror("邮件地址已被占用","tdmail");
                 return false;
           }
            return true;
        }
 function htmlsuccess(str,htmlid){
               $("#"+htmlid).html("");
               $("#"+htmlid).html("<div class=\"Rm_three\">"+str+"</div>");
 }
 function htmlerror(str,htmlid){
       		   $("#"+htmlid).html("");
               $("#"+htmlid).html("<div class=\"Rm_four\">"+str+"</div>");
 }
 function ajaxcheckemail(email){
     $.ajax({
         type: "POST",
         contentType: "application/json",
         url: "TuanService.asmx/CheckEmail",
         data: "{email:'"+email+"'}",
         dataType: 'json',
         success: function(msg) {
             if (msg.d) {
                 htmlerror("邮件地址已占用", "tdmail");
                 $("#ehave").html("");
                 $("#ehave").attr("value", "yes");
             } else {
                 $("#ehave").html("");
                 $("#ehave").attr("value", "no");
                 htmlsuccess("邮箱可用", "tdmail");
             }
         }
     });
 }

 function checkpass(){
     //checkname();
       checkemail();
       var pass = $("#ctl00_ContentPlaceHolder1_pass").val();
	  
	   var conpass = $("#conpass").val();

	   if(pass==""){
                 htmlerror("请输入密码","tdpass");
                 return false;
	   }
	   if(pass.length>20||pass.length<6){
                 htmlerror("密码长度不合法，长度为6至20个字符","tdpass");
                 return false;
	   }
	   if(conpass==""){
		         htmlerror("请输入确认密码","tdconpass");
                 return false;
	   }
	   if(pass!=conpass){
		         htmlerror("两次密码输入不一致","tdconpass");
                 return false;
	   }
	   htmlsuccess("&nbsp;","tdpass");
	   htmlsuccess("&nbsp;","tdconpass");
       return true;
 }

 function checkyzm(){
       var yzm = $("#yzm").val();
	   var v = GetCookie("commentcode");
	   if(yzm==""){
               $("#tdyzm").html("");
               $("#tdyzm").html("<div class=\"Rm_four\">请输入验证码。<font class=\"text6\"><a style=\"cursor:pointer\" onClick=\"DoFresh();return false;\">看不清？换一张！</a></font></div>");
                 return false;
	   }
	   if (yzm.toUpperCase() != v) {
               $("#tdyzm").html("");
               $("#tdyzm").html("<div class=\"Rm_four\">验证码输入错误。<font class=\"text6\"><a style=\"cursor:pointer\" onClick=\"DoFresh();return false;\">看不清？换一张！</a></font></div>");
	             return false;
	   }
	   htmlsuccess("&nbsp;","tdyzm");
       return true;
 }

 function checkname() {
	   // checkemail();
       var name = encodeURI($("#name").val());
   	   if(name==""){
                 htmlerror("请输入昵称","tdname");
                 return false;
	   }
	   if(name.length>100){
                 htmlerror("昵称过长","tdname");
                 return false;
	   }

	    //   ajaxcheckname(name);

         //  var nhave = $("#nhave").val();
           //if(nhave=="yes"){
//                 htmlerror("昵称已被占用","tdname");
              //   return false;
           //}


       return true;
 }

  function ajaxcheckname(name){
	   	   $.ajax({
		       type: "POST",
		       url: "/ucenter/checkname/"+name,
		       "data": "",
		       success: function(msg){
		          if(msg){
		           htmlerror("昵称已占用或不合法","tdname");
		           		$("#nhave").html("");
                        $("#nhave").attr("value","yes");
		          }else{
		           		$("#nhave").html("");
                        $("#nhave").attr("value","no");
						htmlsuccess("昵称可用","tdname");
						//昵称合法直接点击submit
						//$("#signupForm").submit();
		          }
		       }
	       });
 }

//确认邮件那个checkbox验证
function queding(){
          if($("#queding").attr('checked')){
		  return $("#queding").attr('checked');
          }else{
			  alert("请您确认使用了正确的Email地址！");
          return $("#queding").attr('checked');
		  }

}

//同意协议那个checkbox验证
function xieyi(){
          if($("#xieyi").attr('checked')){
		  return $("#xieyi").attr('checked');
          }else{
			  alert("请您确认同意了5151团网使用协议！");
              return $("#xieyi").attr('checked');
		  }

}

 //提交验证
function cSubmit() {
	 if(!checkemail()||!checkpass()||!checkyzm()||!queding()||!xieyi()){
         return false;
	 }else{
         return true;
	 }
 }

 //修改资料提交验证
 function cSubmitYanzheng(){

	 if(!checkname()||!checkemail()||!checkyzm()){
         return false;   
	 }else{
         return true;
	 }
 }